﻿using System.ComponentModel;

namespace Neitzel.Irc
{
    /// <summary>
    /// Configuration Data required to contact a IRC ServerConfig
    /// </summary>
    public class ServerConfig : INotifyPropertyChanged
    {
        #region INotifyPropertyChanged parts

        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            // prevent racing conditions
            var handler = PropertyChanged;

            // trigger event
            handler?.Invoke(sender, e);
        }
        
        #endregion

        #region Properties

        #region ServerConfig Information

        /// <summary>
        /// Gets or sets the hostname of IRC ServerConfig.
        /// </summary>
        public string HostName
        {
            get { return _hostName; }
            set { _hostName = value; OnPropertyChanged(this, new PropertyChangedEventArgs(nameof(HostName))); }
        }
        private string _hostName;

        /// <summary>
        /// Gets or sets the portr that should be used
        /// </summary>
        public int Port
        {
            get { return _port; }
            set { _port = value; OnPropertyChanged(this, new PropertyChangedEventArgs(nameof(Port))); }
        }
        private int _port;

        #endregion

        #region User Information

        /// <summary>
        /// Gets or sets the nickname to use when connecting to the server.
        /// </summary>
        public string Nickname
        {
            get { return _nickname; }
            set { _nickname = value; OnPropertyChanged(this, new PropertyChangedEventArgs(nameof(Nickname))); }
        }
        private string _nickname;

        /// <summary>
        /// Gets or sets the alternative nickname to use in case that the first nickname is already in use.
        /// </summary>
        public string AlternativeNickname
        {
            get { return _alternateNickname; }
            set { _alternateNickname = value; OnPropertyChanged(this, new PropertyChangedEventArgs(nameof(AlternativeNickname))); }
        }
        private string _alternateNickname;

        /// <summary>
        /// Gets or sets the full name of the user.
        /// </summary>
        public string FullName
        {
            get { return _fullName; }
            set { _fullName = value; OnPropertyChanged(this, new PropertyChangedEventArgs(nameof(FullName))); }
        }
        private string _fullName;

        /// <summary>
        /// Gets or sets the email adress of the user.
        /// </summary>
        public string Email
        {
            get { return _email; }
            set { _email = value; OnPropertyChanged(this, new PropertyChangedEventArgs(nameof(Email))); }
        }
        private string _email;

        /// <summary>
        /// Gets or sets a username to send to the server (login name of user).
        /// </summary>
        public string UserName
        {
            get { return _userName; }
            set { _userName = value; OnPropertyChanged(this, new PropertyChangedEventArgs(nameof(UserName))); }
        }
        private string _userName;

        #endregion

        #endregion
    }
}
